using System.Collections.Generic;
using GameFramework.Battle.Core;
using Gameplay.PVE.Config;
using Gameplay.PVE.Entity;
using Gameplay.PVE.Utils;
using UnityEngine;
using Yoozoo.Libs;

namespace Gameplay.PVE.Skill
{
    /// <summary>
    /// 根据扫射动作所对应的枪口方向射子弹的扫射
    /// </summary>
    public class WaveShootNew:SkillCasterBase
    {

        public override void Start(float stateStartTime)
        {
            base.Start(stateStartTime);
            nextShootTime = 0;
            shootIntetval = config.GetCastParam(0);
        }
        
        
        private float shootIntetval;
        private float nextShootTime;
        
        public override void Update(float currentTime)
        {
            if (nextShootTime == 0 || TimeManager.logicTime >= nextShootTime)
            {
                var offset = skill.GetBulletOffset((int)config.bullets[0].z);
                var forward = new Vector3(offset.x, 0, offset.z).normalized;
                forward.y = Random.Range(-0.1f, 0.1f);
                
                skill.CreateBulletByRotation(offset,forward,(int)config.bullets[0].y,0,config.bullets[0].z);
                nextShootTime = TimeManager.logicTime + shootIntetval;
            }
        }
    }
}